package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.VideoVo;
import com.tanhua.server.service.SmallVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * 小视频控制层
 */
@RestController
@RequestMapping("/smallVideos")
public class SmallVideoController {

    @Autowired
    private SmallVideoService smallVideoService;

    /**
     * 发布小视频
     * videoThumbnail:视频封面文件
     * videoFile:视频文件
     */
    @PostMapping
    public ResponseEntity addVideo(MultipartFile videoThumbnail,MultipartFile videoFile){
        smallVideoService.addVideo(videoThumbnail,videoFile);
        return ResponseEntity.ok(null);
    }


    /**
     * 小视频列表
     */
    @GetMapping
    public ResponseEntity findPageVideo(@RequestParam(value = "page",defaultValue = "1") Long page, @RequestParam(value = "pagesize",defaultValue = "10")Long pageSize){
        PageResult<VideoVo> pageResult = smallVideoService.findPageVideo(page,pageSize);
        return ResponseEntity.ok(pageResult);
    }
}
